<template>
	<view class="box">
		<view class="box-content">
		<autograph style="height: 80vh;border: 1px solid #d7cccc;border-radius: 8px" @fj="fileUrl"></autograph>
		</view>
		<view class="btns">
			<u-button type="primary" @click="submit" text="确定"></u-button>
		</view>
	</view>
</template>

<script>
	import autograph from '@/pages/autograph/autograph.vue'
	import { approve } from '../../../api/space.js'
	export default {
		data() {
			return {
				obj:null,
				id:null,
				qmtp:''
			}
		},
		components: {
			autograph
		},
		onLoad(obj) {
			this.obj = JSON.parse(obj.details)
			this.id = this.obj.id
			// console.log(this.obj);
			// console.log(this.id);
		},
		methods: {
			fileUrl(val){
			 this.qmtp= val
			},
			submit(){
				const data ={
					qmtp:this.qmtp,
					checkResult:1,
					zyp:this.id
				}
				if (this.qmtp != '') {
					approve(data).then((res) =>{
						if (res.code == 200) {
							uni.showToast({
							  icon: 'success',
							  duration: 2000,
							  position:'top',
							  title: `审批已通过`
							});
							setTimeout((e) => {
								uni.reLaunch({
									url:'/pages/home/home'
								})
							
							}, 2000)
						}
					})
				}else {
					uni.showToast({
						icon: 'error',
						duration: 2000,
						position:'top',
						title: `请先签字保存`
					});
				}	
			}
		}
	}
</script>

<style lang="scss">
.box{
	width: 100vw;
	// height: calc(100% - 80rpx);
	padding: 40rpx 24rpx;
	box-sizing: border-box;
	.box-content{
		width: 100%;
		height: 80vh;
		border-radius: 16rpx;
		background-color: #f5f5f5;
	}
	.btns{
		width: 100%;
		margin: 40rpx 0 20rpx;
		height: 80rpx;
		display: flex;
		justify-content:space-between;
		.btn{
			width: 280rpx;
			height: 80rpx;
			// background-color: aqua;
			.u-button{
				border: none;
			}
		}
	}
}
</style>
